package com.tech.pattern.strategy;

public class Context {

    // 持有一个抽象策略的引用
    private CashSuper cashSuper;

    // 与简单工厂结合使用降低耦合度
    Context(String type) {
        if (type.equals("normal")) {
            cashSuper = new CashNormal();
        } else if (type.equals("rebeat")) {
            cashSuper = new CashRebeat();
        } else if (type.equals("return")) {
            cashSuper = new CashReturn();
        }
    }

    // 策略方法
    void executeStrategy(double price) {
        cashSuper.getResult(price);
    }
}
